package cn.iocoder.yudao.module.pay.framework;

import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

/**
 * 支付系统异常 Exception
 */
@Getter
@AllArgsConstructor
public class PayException extends ServiceException {
    private final PayError payError;

    public PayException(String errorCode, String errorMsg) {
        this.payError = new PayError(errorCode, errorMsg);
    }

    public PayException(String errorCode, String errorMsg, Throwable cause) {
        super(cause);
        this.payError = new PayError(errorCode, errorMsg);
    }

    public PayException(Throwable cause) {
        super(cause);
        this.payError = new PayError(String.valueOf(GlobalErrorCodeConstants.UNKNOWN.getCode()), cause.getMessage());
    }


    @Data
    @AllArgsConstructor
    public static class PayError {
        private String errorCode;
        private String errorMsg;
    }

}
